1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.google.common.collect;
18
19 import com.google.common.annotations.GwtCompatible;
20 import com.google.common.collect.Multisets.UnmodifiableMultiset;
21
22 import java.util.Comparator;
23 import java.util.NavigableSet;
24
25
26
27
28
29
30
31
32 @GwtCompatible(emulated = true)
33 final class UnmodifiableSortedMultiset<E>
34 extends UnmodifiableMultiset<E> implements SortedMultiset<E> {
35 UnmodifiableSortedMultiset(SortedMultiset<E> delegate) {
36 super(delegate);
37 }
38
39 @Override
40 protected SortedMultiset<E> delegate() {
41 return (SortedMultiset<E>) super.delegate();
42 }
43
44 @Override
45 public Comparator<? super E> comparator() {
46 return delegate().comparator();
47 }
48
49 @Override
50 NavigableSet<E> createElementSet() {
51 return Sets.unmodifiableNavigableSet(delegate().elementSet());
52 }
53
54 @Override
55 public NavigableSet<E> elementSet() {
56 return (NavigableSet<E>) super.elementSet();
57 }
58
59 private transient UnmodifiableSortedMultiset<E> descendingMultiset;
60
61 @Override
62 public SortedMultiset<E> descendingMultiset() {
63 UnmodifiableSortedMultiset<E> result = descendingMultiset;
64 if (result == null) {
65 result = new UnmodifiableSortedMultiset<E>(
66 delegate().descendingMultiset());
67 result.descendingMultiset = this;
68 return descendingMultiset = result;
69 }
70 return result;
71 }
72
73 @Override
74 public Entry<E> firstEntry() {
75 return delegate().firstEntry();
76 }
77
78 @Override
79 public Entry<E> lastEntry() {
80 return delegate().lastEntry();
81 }
82
83 @Override
84 public Entry<E> pollFirstEntry() {
85 throw new UnsupportedOperationException();
86 }
87
88 @Override
89 public Entry<E> pollLastEntry() {
90 throw new UnsupportedOperationException();
91 }
92
93 @Override
94 public SortedMultiset<E> headMultiset(E upperBound, BoundType boundType) {
95 return Multisets.unmodifiableSortedMultiset(
96 delegate().headMultiset(upperBound, boundType));
97 }
98
99 @Override
100 public SortedMultiset<E> subMultiset(
101 E lowerBound, BoundType lowerBoundType,
102 E upperBound, BoundType upperBoundType) {
103 return Multisets.unmodifiableSortedMultiset(delegate().subMultiset(
104 lowerBound, lowerBoundType, upperBound, upperBoundType));
105 }
106
107 @Override
108 public SortedMultiset<E> tailMultiset(E lowerBound, BoundType boundType) {
109 return Multisets.unmodifiableSortedMultiset(
110 delegate().tailMultiset(lowerBound, boundType));
111 }
112
113 private static final long serialVersionUID = 0;
114 }